import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output, TemplateRef, ViewChild } from '@angular/core';

@Component({
  selector: 'wy-carousel',
  templateUrl: './wy-carousel.component.html',
  styleUrls: ['./wy-carousel.component.less'],
  // 只有Input属性的值发生改变了才会对组件进行更新，否则不会更新，有利于提升性能
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class WyCarouselComponent implements OnInit {
  constructor() { }

  @Input() activeIndex: number = 0
  @Output() changeSlide = new EventEmitter<'pre' | 'next'>()
  @ViewChild('dot', {static: true}) dotRef!: TemplateRef<any>

  onChangeSlide(type: 'pre' | 'next'){
    this.changeSlide.emit(type)
  }

  ngOnInit() {
  }

}
